import axios from "axios"
import { API } from '../../config'
import {takeEvery, put } from 'redux-saga/effects'
import { get_products_by_id, get_products_by_id_success} from "../actions/productDetail"


function* hanleGetProductsById(action){
  // console.log(action)
  let response = yield axios.get(`${API}/product/${action.payload.productId}`)
  // console.log(response)
  yield put(get_products_by_id_success(response.data))
}
export default function* productDetailSaga(){
  yield takeEvery(get_products_by_id, hanleGetProductsById)
}
